<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SkyGameEngine2d: Exp_singleton.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="shpe.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">SkyGameEngine2d
   &#160;<span id="projectnumber">1.0.3</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Exp_singleton.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>单例对象的基类 </p><dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>单例类的类型 </td></tr>
    <tr><td class="paramname">is_auto_create</td><td>是否在获取单例对象时自动创建对象</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;../utility/Singleton.h&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">using namespace  </span>SkyEngine2d;</div><div class="line"></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="keyword">class </span>TestSingleton_1</div><div class="line">    :<span class="keyword">public</span> <a name="_a0"></a><a class="code" href="class_sky_engine2d_1_1_singleton.html">Singleton</a>&lt;TestSingleton_1&gt;</div><div class="line">{</div><div class="line">    SINGLETON_CLASS(TestSingleton_1)</div><div class="line"><span class="keyword">public</span>:</div><div class="line">    ~TestSingleton_1() {}</div><div class="line">    <span class="keywordtype">void</span> test(){}</div><div class="line"><span class="keyword">private</span>:</div><div class="line">    TestSingleton_1() {}</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">class </span>TestSingleton_2</div><div class="line">    :<span class="keyword">public</span> <a class="code" href="class_sky_engine2d_1_1_singleton.html">Singleton</a>&lt;TestSingleton_2, false&gt;</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">    TestSingleton_2(){}</div><div class="line">    ~TestSingleton_2(){}</div><div class="line">    <span class="keywordtype">void</span> test(){}</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">    </div><div class="line"><span class="preprocessor">#if 0</span></div><div class="line">    TestSingleton_1::getInstance()-&gt;test();</div><div class="line"><span class="preprocessor">#else</span></div><div class="line">    TestSingleton_2* p = <span class="keyword">new</span> TestSingleton_2;</div><div class="line"></div><div class="line">    TestSingleton_2::getInstance()-&gt;test();</div><div class="line"></div><div class="line">    <span class="keyword">delete</span> p;</div><div class="line">    p = <span class="keyword">nullptr</span>;</div><div class="line"></div><div class="line"><span class="preprocessor">#endif // 0</span></div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
